import os.path
import nltk

def checkNltkData(resource_name,storePath):
    try:
        nltk.data.find(resource_name, paths=[storePath])
        print(f"{resource_name}已经存在")
    except LookupError:
        print(f"{resource_name}不存在，需要重新下载")
        name = os.path.basename(resource_name)
        nltk.download(name, download_dir=storePath)

def checkNltk(storePath):
    """
    初始化Nltk
    """
    checkNltkData('corpora/stopwords',storePath)
    checkNltkData('tokenizers/punkt_tab',storePath)
